import request from '@/utils/request'

/**
 * 查询岗位列表
 */
export function getPostList(query?: any) {
  return request.get('/system/post/list', query)
}

/**
 * 查询岗位详细
 */
export function getPost(postId: number) {
  return request.get(`/system/post/${postId}`)
}

/**
 * 新增岗位
 */
export function addPost(data: any) {
  return request.post('/system/post', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '岗位新增成功',
  })
}

/**
 * 修改岗位
 */
export function updatePost(data: any) {
  return request.put('/system/post', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '岗位修改成功',
  })
}

/**
 * 删除岗位
 */
export function delPost(postIds: number | number[]) {
  const ids = Array.isArray(postIds) ? postIds.join(',') : postIds
  return request.delete(`/system/post/${ids}`, {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '岗位删除成功',
  })
}

/**
 * 导出岗位
 */
export function exportPost(query?: any) {
  return request.post('/system/post/export', query, {
    responseType: 'blob',
    showLoading: true,
  })
}
